#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rep(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii<=Ii##_;Ii++)
#define per(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii>=Ii##_;Ii--)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double db;
#define fir first
#define sec second
#define siz(Aa) ((int)(Aa).size())
#define all(Aa) (Aa).begin(),(Aa).end()
#define ckmx(Aa,Bb) (Aa=max(Aa,Bb))
#define ckmn(Aa,Bb) (Aa=min(Aa,Bb))
#define Fi(s) freopen(s,"r",stdin)
#define Fo(s) freopen(s,"w",stdout)
#define Fre(s) Fi(s".in"),Fo(s".out")

const int N=100010;
int n;
vector<int> e[N];
priority_queue<pair<int,int>> f[N];
void dfs(int rt,int fa){
	for(int i:e[rt]) if(i!=fa){
		dfs(i,rt);
		if(siz(f[rt])<siz(f[i])) swap(f[rt],f[i]);
		while(!f[i].empty()) f[rt].emplace(f[i].top()),f[i].pop();
	}
	if(siz(f[rt])==0) f[rt].emplace(1,0);
	else if(siz(f[rt])==1){
		auto x=f[rt].top();
		f[rt].pop();
		if(x.sec){
			x.sec=0;
			x.fir+=2;
		}else{
			x.sec=1;
		}
		f[rt].emplace(x);
	}else{
		auto x=f[rt].top();
		f[rt].pop();
		auto y=f[rt].top();
		f[rt].pop();
		f[rt].emplace(x.fir+y.fir+1,x.sec|y.sec);
		if(x.sec&&y.sec) f[rt].emplace(1,0);
	}
}
signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);
	Fre("bird");
	cin>>n;
	rep(i,1,n-1){
		int x,y;cin>>x>>y;
		e[x].emplace_back(y);
		e[y].emplace_back(x);
	}
	dfs(1,0);
	auto tmp=f[1].top();
	cout<<tmp.fir+tmp.sec<<"\n";
return 0;}
/*
*/